import java.util.Arrays;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * user:likai
 * Date:2022-10-19
 * Time:9:11
 */
 class Solution {

    Stack<Integer> stack = new Stack <>();
    Stack<Integer> minStack = new Stack <>();

    public void push(int node) {
        stack.push(node);
        if (!minStack.empty()) {
            if (minStack.peek() >= node) {
                minStack.push(node);
            }
        } else {
            minStack.push(node);
        }
    }

    public void pop() {
        if (!stack.empty()) {
            int ret = stack.pop();
            if (minStack.peek() == ret) {
                minStack.pop();
            }
        }
    }

    public int top() {
        if (!stack.empty()) {
            return stack.peek();
        }
        return -1;

    }

    public int min() {
        if (minStack.empty()) {
            return -1;
        } else {
            return minStack.peek();
        }
    }
}
public class MyStack {
    public int val;
    public static final int DEFAULT_SIZE=10;
    int []elem=new int[DEFAULT_SIZE];
    public int usesize;
    public  int push(int val){
        if(usesize==elem.length){
            elem= Arrays.copyOf(elem,2*elem.length);
        }
        elem[usesize]=val;
        usesize++;
        return val;
    }
    public int pop(){
        if(usesize==0){
            throw new MyStackExcpetion("空栈");
        }
        return elem[--usesize];
    }
    public int peek(){
        if(usesize==0){
            throw new MyStackExcpetion("空栈");
        }
        return elem[usesize-1];
    }
    public static void main(String[] args) {
        MyStack myStack=new MyStack();
        MyStack minMyStack=new MyStack();

    }
}
